extends CanvasLayer

var score = 0 setget set_score
signal msgShowOver


func clear_score() -> void:
	score = 0
	$score/scoreLab.text = "得分：" + str(score)

func add_score(num:int) -> void:
	score += num
	$score/scoreLab.text = "得分：" + str(score)

func set_score(num:int) -> void:
	score += num
	$score/scoreLab.text = "得分：" + str(score)


func showMSG(msg:String) -> void:
	$msgLab.visible = true
	$msgLab.text = msg
	$msgLab/msgTimer.start()

func show_lavel_name():
	$level/lavelLab.text = "Level" + str(Global.current_level)

func _on_msgTimer_timeout():
	$msgLab.text = ""
	$msgLab.visible = false
	emit_signal("msgShowOver")
	pass


func _on_ToolButton_pressed():
	if Global.is_bgm_playing:
		Global.bgm_pause()
		$HBox/bgmBtn.icon = load("res://imgs/stop.png")
	else:
		Global.bgm_resume()
		$HBox/bgmBtn.icon = load("res://imgs/play.png")
	pass


func _on_gameBtn_pressed():
	if Global.is_game_playing:
		Global.game_pause()
		$HBox/gameBtn.icon = load("res://imgs/playgame.png")
	else:
		Global.game_resume()
		$HBox/gameBtn.icon = load("res://imgs/pausegame.png")
	pass 


func _on_speedBtn_pressed():
	if Global.time_scale == 1.0:
		Global.time_scale = 2.0
		$HBox/speedBtn.icon = load("res://imgs/twoSpeed.png")
	else:
		Global.time_scale = 1.0
		$HBox/speedBtn.icon = load("res://imgs/oneSpeed.png")
	pass
